package com.aispeech.jarpc.message;

public enum EMsgType {
    UNKNOWN(0),
    JSON(1),
    BINARY(2),
    STOP(16),
    HEALTH(3),
    ERROR(4),
    CLOSE(5),
    PROCESS(6),
    REDIRECT(7),
    ;

    private byte value;

    EMsgType(int value) {
        this.value = (byte)(value & 0xff);
    }

    public static EMsgType from(byte b) {
        EMsgType msgType = null;

        for (EMsgType type : EMsgType.values()) {
            if (type.value == b) {
                msgType = type;
                break;
            }
        }

        return msgType;
    }

    public byte getValue() {
        return value;
    }
}